/**
 * 
 */
package com.xbang.attendance.web.action.warehouse.warn;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.xbang.attendance.entity.stock.InventoryWarningRecord;
import com.xbang.attendance.schedule.WarningScheduleProcess;
import com.xbang.attendance.service.ProductService;
import com.xbang.attendance.service.SystemService;
import com.demo2do.lighturl.annotation.Action;
import com.xbang.core.page.Result;
import com.xbang.core.struts.support.SearchActionSupport;

/**
 * @author dev.zhang
 */
public class Index extends SearchActionSupport {

	private static final long serialVersionUID = 2886204759816132683L;

	@Autowired
	private SystemService systemService;

	@Autowired
	private ProductService productService;

	private Integer id;

	private List<InventoryWarningRecord> inventoryWarningRecords = new ArrayList<InventoryWarningRecord>();

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.opensymphony.xwork2.ActionSupport#execute()
	 */
	@Override
	public String execute() throws Exception {

		return super.execute();
	}

	@Override
	public void resetCustomerSearchCriteria() {
		// TODO Auto-generated method stub

	}

	@Action("/warehouse/warn/${id}/delete")
	public String delete() throws Exception {

		if (id != null) {
			productService.delete(InventoryWarningRecord.class, id);
		}
		return "r:/warehouse/warn/list";
	}

	@Action("/warehouse/warn/list")
	public String list() throws Exception {

		String hqlSentence = "FROM InventoryWarningRecord inventorywarningrecord  WHERE 1 = 1 ";

		Result result = productService.searchByPage(hqlSentence, searchComponent, page);

		inventoryWarningRecords = result.getItems();
		page = result.getPage();

		return "index";
	}

	/**
	 * @return the inventoryWarningRecords
	 */
	public List<InventoryWarningRecord> getInventoryWarningRecords() {
		return inventoryWarningRecords;
	}

	/**
	 * @param inventoryWarningRecords
	 *            the inventoryWarningRecords to set
	 */
	public void setInventoryWarningRecords(List<InventoryWarningRecord> inventoryWarningRecords) {
		this.inventoryWarningRecords = inventoryWarningRecords;
	}

	/**
	 * @return the id
	 */
	public Integer getId() {
		return id;
	}

	/**
	 * @param id
	 *            the id to set
	 */
	public void setId(Integer id) {
		this.id = id;
	}

}
